use ffmpeg_sys_next::{
    av_fifo_alloc2, av_fifo_read, av_fifo_write, av_q2d, av_rescale, av_samples_get_buffer_size, AVFifo, AVRational, AVSampleFormat
};
use std::ffi::{c_double, c_int, c_uint, c_void};

pub fn av_q2d_safe(a: AVRational) -> c_double {
    unsafe { av_q2d(a) }
}

pub fn av_samples_get_buffer_size_safe(
    linesize: *mut c_int,
    nb_channels: c_int,
    nb_samples: c_int,
    sample_fmt: AVSampleFormat,
    align: c_int,
) -> c_int {
    unsafe { av_samples_get_buffer_size(linesize, nb_channels, nb_samples, sample_fmt, align) }
}

pub fn av_fifo_alloc2_safe(elems: usize, elem_size: usize, flags: c_uint) -> *mut AVFifo {
    unsafe { av_fifo_alloc2(elems, elem_size, flags) }
}

pub fn av_fifo_read_safe(f: *mut AVFifo, buf: *mut c_void, nb_elems: usize) -> c_int {
    unsafe { av_fifo_read(f, buf, nb_elems) }
}

pub fn av_fifo_write_safe(f: *mut AVFifo, buf: *const c_void, nb_elems: usize) -> c_int {
    unsafe { av_fifo_write(f, buf, nb_elems) }
}

pub fn av_rescale_safe(a: i64, b: i64, c: i64) -> i64 {
    unsafe { av_rescale(a, b, c) }
}
